package com.hdax.dm.common;

import com.hdax.dm.exception.DmException;

public class ResponseUtil<T>{


    /**
     * 正确响应数据
     * @param data
     * @return
     * @param <T>
     */
    public static<T> CommonResponse returnSuccess(T data){
        return new CommonResponse(data);
    }

    /**
     * 错误响应数据
     * @param msg
     * @param errorCode
     * @return
     * @param <T>
     */
    public static<T> CommonResponse returnFail(String msg,String errorCode){
        return new CommonResponse(errorCode,msg);
    }

    public static CommonResponse returnFail(DmException exception){
        return returnFail(exception.getErrorCode(),exception.getMessage());
    }
}
